package fun.qu_an.minecraft.mini_games_helper.client.mixin.recipebook;

import fun.qu_an.minecraft.mini_games_helper.client.handle.ForceOptionHelperVanilla;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.toast.RecipeToast;
import net.minecraft.client.toast.ToastManager;
import net.minecraft.recipe.RecipeEntry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(RecipeToast.class)
public class RecipeToastMixin {
	@Inject(method = "show(Lnet/minecraft/client/toast/ToastManager;Lnet/minecraft/recipe/RecipeEntry;)V",
		at = @At("HEAD"), cancellable = true)
	private static void onShow(ToastManager manager, RecipeEntry<?> recipe, CallbackInfo ci) {
		if (MinecraftClient.getInstance().interactionManager != null
			&& ForceOptionHelperVanilla.isDisableRecipeBook(MinecraftClient.getInstance().interactionManager.getCurrentGameMode())) {
			ci.cancel();
		}
	}
}
